package com.ardf.common;


import lombok.Data;
/**
 * author:容伟洪
 * time:2025-2-24
 * description：用于前端控制器返回的数据格式
 */
@Data
public class ReturnResult {
    private String code; //状态码
    private String message;//返回信息
    private Object data; //携带数据

    public ReturnResult() {

    }

    public ReturnResult(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ReturnResult(CodeEnum codeEnum) {
        this.code = codeEnum.code;
        this.message = codeEnum.message;
    }


    public static ReturnResult success(CodeEnum codeEnum, Object data){
        ReturnResult result=new ReturnResult();
        result.setCode(codeEnum.code);
        result.setMessage(codeEnum.message);
        result.data=data;
        return result;
    }


    public static ReturnResult error(CodeEnum codeEnum){
        ReturnResult result=new ReturnResult();
        result.setCode(codeEnum.code);
        result.setMessage(codeEnum.message);
        return result;
    }



}
